package com.android.lovely.room.role

import androidx.paging.PagingSource
import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import kotlinx.coroutines.flow.Flow

/**
 *
 * @author why
 * @date 2025/4/6 17:14
 */
@Dao
interface CreateRoleDao {

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun save(value: CreateRole): Long

    @Query("UPDATE CreateRole SET id = :id WHERE id = :localeId")
    suspend fun updateId(localeId: Int, id: Int)

    @Query("select * from CreateRole where id=:id")
    fun getRoleFlow(id: Int): Flow<CreateRole?>

    @Query("select * from CreateRole where id=:id")
    suspend fun getRole(id: Int): CreateRole?

    @Query("select * from CreateRole order by create_time DESC")
    fun getRoles(): List<CreateRole>

    @Query("delete from CreateRole where id=:id")
    suspend fun delete(id: Int)
}